package mapper

import (
	"github.com/beego/beego/v2/client/orm"
	"ksd-social-api/modules/course/model"
)

type CourseMapper struct{}

/**
 * @author feige
 * @date 2023-10-08
 * @desc 根据id查询课程信息
 */
func (mapper *CourseMapper) GetById(id uint64) (course *model.Course, err error) {
	// 1: 创建一个数据连接
	db := orm.NewOrm()
	// 2: 赋予id给结构体
	dbCourse := model.Course{ID: id}
	// 3: 读取id的数据放入到结构体，进行返回
	err = db.Read(&dbCourse)
	// 4: 结构返回
	return &dbCourse, err
}
